﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>WebSocket Test</title>
    <script language="javascript" type="text/javascript">
        var wsUri = "ws://localhost:10270";
        var output;
        var websocket;
        function init() {
            output = document.getElementById("output");

            document.getElementById('connect').onclick = function (e) {
                testWebSocket();
            };
        }

        function testWebSocket() {
            if (!websocket) {
                websocket = new WebSocket(wsUri);
                websocket.onopen = function (evt) {
                    onOpen(evt)
                };
                websocket.onclose = function (evt) {
                    onClose(evt)
                };
                websocket.onmessage = function (evt) {
                    onMessage(evt)
                };
                websocket.onerror = function (evt) {
                    onError(evt)
                };
            } else {
                onOpen();
            }
           
        }

        function onOpen(evt) {
            writeToScreen("CONNECTED");
            var data = { "OptType": 6, "FilePath": "8e98d24306bd4ec4b154b0294fab0cae.doc", "DocCode": "testdoccode" }
         
   data = {
            "Id": "e877580600154d219f9287ecd3f593c1",
            "OptType": 9,
       "FilePath": "http://localhost:5276/wordTemplate.DOC",
            "RedPath": "http://localhost:5276/工作联系单.doc",
            "VerPath": "http://localhost:5276/a3.doc",
            "OpenType": 0,
            "Params": "{'￥￥Dta':'二零二三','￥￥mtype':'','￥￥mlevel':'','￥￥hlevel':'','￥￥title':'中建投办签','￥￥year':'2023','￥￥number':'1','￥￥subject':'cc-qb-2023-01-009','￥￥cbr':'123','￥￥fujian':'','￥￥cdate':'2023年1月9日','￥￥fjbt':'','￥￥ngbm':'其他'}", "User": "admin", "DocCode": "fbed40f1595c42e7b0c05246e8465f02", "IsForce": false,
            "SessionId": "993EA213005C3DF17CA02D9EA432E6BA",
            "Token": "f11df57a2dcc71048765e0db74d3d395",
            "UploadPath": "http://localhost:5000/home/upload",
            "FileName": null, "FileDirectory": null,
            "IsReadOnly": false,
            "CopyHeader": true
        }
        //data = { "OptType": 6, "FilePath": "8e98d24306bd4ec4b154b0294fab0cae.doc" }

        //data = {
        //    "Id": "e877580600154d219f9287ecd3f593c1",
        //    "OptType": 8,
        //    "FilePath": "http://localhost:5276/abc.xlsx",
        //    "RedPath": "http://localhost:5276/工作联系单.doc",
        //    "VerPath": "http://localhost:5276/a3.doc",
        //    "OpenType": 0,
        //    "Params": "{'￥￥Dta':'二零二三','￥￥mtype':'','￥￥mlevel':'','￥￥hlevel':'','￥￥title':'中建投办签','￥￥year':'2023','￥￥number':'1','￥￥subject':'cc-qb-2023-01-009','￥￥cbr':'123','￥￥fujian':'','￥￥cdate':'2023年1月9日','￥￥fjbt':'','￥￥ngbm':'其他'}", "User": "admin", "DocCode": "fbed40f1595c42e7b0c05246e8465f02", "IsForce": false,
        //    "SessionId": "993EA213005C3DF17CA02D9EA432E6BA",
        //    "Token": "f11df57a2dcc71048765e0db74d3d395",
        //    "UploadPath": "http://localhost:5000/home/upload",
        //    "FileName": null, "FileDirectory": null,
        //    "IsReadOnly": false,
        //    "CopyHeader": true
        //}
        doSend(JSON.stringify(data));

                //doSend(JSON.stringify({
                //    "OptType": 7,
                //    "FilePath": "http://localhost:5276/wordTemplate.DOC",
                //    "RedPath": "http://localhost:5276/ht.DOC",
                //    "VerPath": "http://localhost:5276/bj.DOC",
                //    "OpenType": 0,
                //    "Params": "{'￥￥FYTFS':'议题1'}",
                //    "User": "com.lm.web.entity.user.AppUser@6fcf2f86",
                //    "DocCode": "testdoccode",
                //    "SessionId": "75F38BDBC6BFEE57F48A1CF54616FCA3",
                //    "Token": "f11df57a2dcc71048765e0db74d3d395",
                //    "UploadPath": "http://127.0.0.1:5276/home/upload",
                //    "FileName": "这是一个测试1.txt"
                //}));

                //doSend(JSON.stringify({
                //    "OptType": 7,
                //    "FilePath": "http://localhost:5276/wordTemplate.DOC",
                //    "RedPath": "http://localhost:5276/ht.DOC",
                //    "VerPath": "http://localhost:5276/bj.DOC",
                //    "OpenType": 0,
                //    "Params": "{'￥￥FYTFS':'议题1'}",
                //    "User": "com.lm.web.entity.user.AppUser@6fcf2f86",
                //    "DocCode": "testdoccode",
                //    "SessionId": "75F38BDBC6BFEE57F48A1CF54616FCA3",
                //    "Token": "f11df57a2dcc71048765e0db74d3d395",
                //    "UploadPath": "http://127.0.0.1:5276/home/upload",
                //    "FileName": "这是一个测试2.txt"
                //}));
            }

        function onClose(evt) {
            writeToScreen("DISCONNECTED");
        }

        function onMessage(evt) {
            writeToScreen('<span style="color: blue;">RESPONSE: ' + evt.data + '</span>');
           // websocket.close();
        }

        function onError(evt) {
            writeToScreen('<span style="color: red;">ERROR:</span> ' + evt.data);
        }

        function doSend(message) {
            writeToScreen("SENT: " + message);
            websocket.send(message);
        }

        function writeToScreen(message) {
            var pre = document.createElement("p");
            pre.style.wordWrap = "break-word";
            pre.innerHTML = message;
            output.appendChild(pre);
        }
        window.addEventListener("load", init, false);
    </script>
</head>
<body>
    <h2>WebSocket Test</h2>
    <input type="button" id="connect" value="连接WebSocket" />
    <div id="output"></div>
</body>
</html>
<script>

</script>